package com.luci.security;

import com.luci.security.support.IAuth;
import java.util.Collection;
import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.FilterInvocation;

/**
 * 决策管理器
 *
 * @author yuyanan01@beyondsoft.com
 * @version 1.0
 * @date 18-11-17
 */
public class DefaultAccessDecisionManager implements AccessDecisionManager {

    private IAuth iAuth;

    public DefaultAccessDecisionManager(IAuth iAuth) {
        this.iAuth = iAuth;
    }

    @Override
    public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes)
        throws AccessDeniedException, InsufficientAuthenticationException {
        FilterInvocation invocation = (FilterInvocation) object;
        iAuth.decide(authentication, configAttributes, invocation);

    }

    @Override
    public boolean supports(ConfigAttribute configAttribute) {
        return true;
    }

    @Override
    public boolean supports(Class<?> aClass) {
        return true;
    }


}
